﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace SPWarmup
{
    public static class WarmUpRequest
    {
        /// <summary>
        /// Creates a synchronous request to the specified URL.
        /// </summary>
        /// <param name="url">The URL.</param>
        public static void Create(string url)
        {
            try
            {
                var request = WebRequest.Create(url);
                request.Method = "GET";
                request.UseDefaultCredentials = true;
                //Block until a response is received
                using (var response = request.GetResponse()) { }
            }
            catch (WebException webException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception("A general error occured while requesting " + url, ex);
            }
        }
    }
}
